// pages/mess.js
const app = getApp()
Page({
  /**
   * 页面的初始数据
   */
  data: {
    notmess:[],
    id: '',
    textarea:'',
    orderId: ''
  },
  mess(event){
    wx.switchTab({
        url:'/pages/orderform/orderform',
    })
 },

 onChange(event) {
  // event.detail 为当前输入的值
  console.log(event.detail);
  this.setData({
    textarea: event.detail
  })
},
  /**
   * 生命周期函数--监听页面加载
   */
  getmess(){
    const value = wx.getStorageSync('token');
    let that = this;
    console.log(this.data.textarea)
    // console.log(e.id)
        wx:wx.request({
            url: app.globalData.baseurl+'/comment/insertComment',
            method: 'post',
            data: {
              commentContent: this.data.textarea,
              orderId: this.data.orderId,
              statusId: 7,
              sid: 8,
              },
            header: {
              'content-type': "application/json",
              'Authorization':value,
            },
            success(res){
              console.log(res)
              that.setData({
                getmess: res.data
              });
              wx.showToast({
                title: "提交评价成功！",
                icon: 'none',
                duration: 2000
              })
            }
          })
  },

  onLoad: function (e) {
    const value = wx.getStorageSync('token');
    let that = this;
    console.log(e.id)
    this.setData({
      orderId: e.id
    })
    // id: e.id
    console.log(this.data.orderId)
    wx:wx.request({
      url: app.globalData.baseurl+'/orderForm/getOrder',
      method: 'POST',
      data: {
        orderId: e.id,
      },
      header: {
        'content-type': "application/json",
        'Authorization':value,
      },
      success(res){
        console.log(res)
        that.setData({
          notmess: res.data
        })
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})